package com.ruoyi.kjy.config;/**
 * @InterfaceName: RabbitmqConfig
 * @Description:
 * @Author: YourName
 * @Date: 2023-04-19
 */

import com.ruoyi.kjy.controller.AchievementController;
//import org.springframework.amqp.core.*;
//import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
//import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 *@InterfaceName: RabbitmqConfig
 *@Description:
 *@Author: lilirui
 *@Date: 2023-04-19
 */
@Configuration
@ConditionalOnProperty(name="websocket.enabled",havingValue = "true")
public class RabbitmqConfig {
    // 没用上

    final public static String EXCHANGENAME = "websocketExchange";

//    /**
//     * 创建交换器
//     */
//    @Bean
//    FanoutExchange exchange() {
//        return new FanoutExchange(EXCHANGENAME);
//    }
//
//    @Bean
//    public Queue queue(){
//        return new Queue(orderQueueName());
//    }
//
//    @Bean
//    Binding bindingExchangeMessage(Queue queue, FanoutExchange exchange) {
//        return BindingBuilder.bind(queue).to(exchange);
//    }

//    @Bean
//    public SimpleMessageListenerContainer messageListenerContainer(AchievementController achievementController, @Qualifier("rabbitConnectionFactory") CachingConnectionFactory cachingConnectionFactory){
//        SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(cachingConnectionFactory);
//        // 监听队列的名称
//        container.setQueueNames(orderQueueName());
//        container.setExposeListenerChannel(true);
//        // 设置每个消费者获取的最大消息数量
//        container.setPrefetchCount(100);
//        // 消费者的个数
//        container.setConcurrentConsumers(1);
//        // 设置确认模式为自动确认
//        container.setAcknowledgeMode(AcknowledgeMode.AUTO);
//        container.setMessageListener(achievementController);
//        return container;
//    }


    /**
     * 在这里写获取订单队列名的具体过程
     * @return
     */
    public String orderQueueName(){
        return "orderChannel";
    }
}